//随机数字
@function parse-random($value) {
  @return round(random() * $value);
}
$randomId: parse-random(1000000);
$basePx:75px;
$spriteSrc: "../images/sprite.png?_v=1.2.1";
$spriteWidth: 430px;
$spriteHeight: 260px;
$arrow: -346px -194px 48px 48px;
$end-point: -244px -110px 84px 92px;
$road: 0px 0px 236px 260px;
$site-big: -244px 0px 94px 102px;
$site-small: -346px -100px 78px 86px;
$start-point: -346px 0px 84px 92px;
$xiegang: -402px -194px 16px 28px;

@function px2rem ($px) {
  @if (type-of($px) == "number") {
    @return $px / $basePx * 1rem;
  }
  @if (type-of($px) == "list") {
    @if (nth($px, 1) == 0 and nth($px, 2) != 0) {
      @return 0 nth($px, 2) / $basePx * 1rem;
    } @else if (nth($px, 1) == 0 and nth($px, 2) == 0)  {
      @return 0 0;
    } @else if (nth($px, 1) != 0 and nth($px, 2) == 0) {
      @return nth($px, 1) / $basePx * 1rem 0;
    } @else {
      @return nth($px, 1) / $basePx *1rem nth($px, 2) / $basePx * 1rem;
    }
  }
}

@function strip-units($number){
  @return $number / ($number * 0 + 1);
}

@function format-zero($number){
	@if $number == 0 {
		@return 1;
	}@else{
		@return $number;
	}
}

@mixin sprite-width($sprite, $precision) {
	@if $precision {
		width: px2rem(nth($sprite, 3));
	}@else{
		width: px2rem(nth($sprite, 3) + 2px);
	}

}

@mixin sprite-height($sprite, $precision) {
	@if $precision {
		height: px2rem(nth($sprite, 4));
	}@else{
		height: px2rem(nth($sprite, 4) + 2px);
	}
}

@mixin sprite-position($sprite, $precision) {
	@if $precision {
		background-position: strip-units(nth($sprite, 1)) / strip-units(nth($sprite, 3) - $spriteWidth) * 100%  strip-units(nth($sprite, 2)) / format-zero(strip-units(nth($sprite, 4) - $spriteHeight)) * 100%;
	}@else{
		background-position: strip-units(nth($sprite, 1)) / strip-units(nth($sprite, 3) + 1 - $spriteWidth) * 100%  strip-units(nth($sprite, 2)) / format-zero(strip-units(nth($sprite, 4) + 1 - $spriteHeight)) * 100%;
	}
}

@mixin sprite($sprite, $precision) {
	@include sprite-position($sprite, $precision);
	@include sprite-width($sprite, $precision);
	@include sprite-height($sprite, $precision);
  background-image: url('#{$spriteSrc}');
	background-repeat: no-repeat;
	background-size: px2rem(($spriteWidth, $spriteHeight));
  display: inline-block;
}


.icon-arrow {
    @include sprite($arrow, $precision: false);
}
.icon-end-point {
    @include sprite($end-point, $precision: false);
}
.icon-road {
    @include sprite($road, $precision: false);
}
.icon-site-big {
    @include sprite($site-big, $precision: false);
}
.icon-site-small {
    @include sprite($site-small, $precision: false);
}
.icon-start-point {
    @include sprite($start-point, $precision: false);
}
.icon-xiegang {
    @include sprite($xiegang, $precision: false);
}
